public class Tree {
      class TreeNode {
          int val;
          TreeNode left;
          TreeNode right;
          TreeNode(int x) { val = x; }
      }


        public static int i;
        public int find(int[] preorder,int[] inorder) {
            for(int j = 0;j < inorder.length;j++) {
                if(preorder[i] == inorder[j]) {
                    return j;
                }
            }
            return -1;
        }
        public TreeNode func(int[] preorder,int[] inorder,int start, int end) {
            if(start > end) {
                return null;
            }
            int index = find(preorder,inorder);
            TreeNode root = new TreeNode(inorder[i++]);
            root.left = func(preorder,inorder,start,index-1);
            root.right = func(preorder,inorder,index+1,end);

            return root;
        }

        public TreeNode buildTree(int[] preorder, int[] inorder) {
            return func(preorder,inorder,0,preorder.length-1);
            String
        }

}
